package me

import grails.converters.JSON
import groovy.sql.Sql
import groovy.json.*

class FiletypeController {

    def index() { }

    def store() {

    	def results = []


    	results = FileType.findAll("""from FileType order by dateCreated desc""")

		if(params.flag!=null) {
			results.add(0, [cnName:"修改文件类型",id:-1]);
		}
		results = [success:true,total:results.size()+1,results:results]
		render results  as JSON


  	}


  	def delete() {
  		def ds = FileType.findById(params.id)
  		println ds
  		ds.delete(flush: true) 
  		def results = [success:true]
    	render results as JSON
  	}

  	def save() {
  		def resuls = [success:true]
   		
   		def fileType = new FileType(cnName: params.cnName)
		fileType.save(failOnError: true)
    	
    	
    	render resuls as JSON
  	}
}
